<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of EventLinkPerson
 *
 * @author johnnypark
 */
class Model_EventLinkPerson extends Model_Base
{

    protected $name = 'event_link_person';

    public function create(array $eventLinkPerson)
    {
	$this->db->insert($this->name, $eventLinkPerson);
	return $this->db->lastInsertId($this->name);
    }

    public function listAll()
    {
	$select = $this->db->select()
		->from($this->name);
	return $this->db->fetchAll($select);
    }

    public function find($id)
    {
	$select = $this->db->select()
		->from($this->name)
		->where('id = ?', $id);
	return $this->db->fetchRow($select);
    }

    public function findByPerson($idperson)
    {
	$select = $this->db->select()
		->from($this->name)
		->where('idperson = ?', $idperson);
	return $this->db->fetchRow($select);
    }

    public function findByEvent($idevent)
    {
	$select = $this->db->select()
		->from($this->name)
		->where('idevent = ?', $idevent);
	return $this->db->fetchRow($select);
    }

    public function deleteAll()
    {
	$this->db->delete($this->name);
    }

}

?>
